package com.csj.DesignPattern.command;

import java.util.ArrayList;
import java.util.List;

public class Waitor {

    private List<Command> commands = new ArrayList<>();

    public void setCommand(Command command) {
        commands.add(command);
    }

    public void orderUp() {
        System.out.println("订单来了");
        if (!commands.isEmpty()) {
            commands.forEach(Command::execute);
        }
    }
}
/*
//相当于Waitor
public class Thread implements Runnable {

    //Runnable相当于Command
    //相当于commands
    private Runnable target;

    //相当于orderUp()
    public synchronized void start() {
        start0();
    }
}

 */